using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;

namespace Lync.Widget.Library.Configuration
{
    public class LanguagePacksConfigurationSection : ConfigurationSection, ILanguagePackConfiguration
    {
        [ConfigurationProperty("Languages", IsDefaultCollection = true)]
        private LanguageElementCollection LanguageElementCollection
        {
            get
            {
                var temp = base["Languages"] as LanguageElementCollection;
                return temp;
            }
        }

        public IList<ILanguagePack> LanguagePacks
        {
            get { return LanguageElementCollection.Cast<ILanguagePack>().ToList(); }
        }

        public static LanguagePacksConfigurationSection Load()
        {
            LanguagePacksConfigurationSection section = null;
            try
            {
                var temp = ConfigurationManager.GetSection("languagePacks");

                section = temp as LanguagePacksConfigurationSection;
            }
            catch (Exception exception)
            {                                
            }
            return section;
        }
      
    }
}